package main

import (
	"encoding/json"
	"fmt"
	"io"
	"net/http"
)

type ResponseData struct {
	Data int `json:"data"`
}

func Add(a, b int) int {
	res, _ := http.Get(fmt.Sprintf("http://localhost:8080/add?a=%d&b=%d", a, b))
	defer res.Body.Close()

	body, _ := io.ReadAll(res.Body)
	fmt.Println(string(body))
	rspData := ResponseData{}
	json.Unmarshal(body, &rspData)
	return rspData.Data
}

func main() {
	fmt.Println(Add(4, 5))
}
